#include "ui.h"

//--------------------------------显示部分--------------------------------------------------------------------
UiControlDef UI;
//功能菜单界面
void mainMenu_ui1(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[mainMenu])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[mainMenu]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(120,8, 210, 24, 32, (uint8_t *)"Function Menu");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210,80+1,100, 24, 24, (uint8_t *)"Coordina");
		LCD_ShowString(210,80+1+24,100, 24, 24, (uint8_t *)" Control");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+5,80+1,450, 24, 24, (uint8_t *)"Setting");
		LCD_ShowString(350+5,80+1+24,450, 24, 24, (uint8_t *)"  Menu ");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+5,160+1,450, 24, 24, (uint8_t *)"  Outer");
		LCD_ShowString(210+5,160+1+24,450, 24, 24, (uint8_t *)"  Frame");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350,160+1,450, 24, 24, (uint8_t *)"  Inner ");
		LCD_ShowString(350,160+1+24,450, 24, 24, (uint8_t *)"  Frame ");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+5,240+1,450, 24, 24, (uint8_t *)"NAN");
		LCD_ShowString(210,240+1+24,450, 24, 24, (uint8_t *)"NAN");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+5,240+1,450, 24, 24, (uint8_t *)"NAN");
 		LCD_ShowString(350,240+1+24,450, 24, 24, (uint8_t *)"NAN");
 		goHome();
	}

};

//坐标控制界面
void coorCtrl_ui2(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[coorCtrl])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[coorCtrl]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		LCD_DrawLine(0, 160, 180, 160);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(80,8, 300, 24, 32, (uint8_t *)"Coordinate control");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"1 Uint");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"2 Uint");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,160+10,450, 24, 24, (uint8_t *)"5 Uint");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+5,160+10,450, 24, 24, (uint8_t *)"40 Uint");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+12,240+10,450, 24, 32, (uint8_t *)"Reset");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
		BACK_COLOR = RED;
		POINT_COLOR = WHITE;
		LCD_Fill(60,165,60+60,165+35,RED);
		LCD_ShowString(60+8,165,450, 24, 32, (uint8_t *)" U");
		LCD_Fill(5,222,5+60,222+35,RED);
		LCD_ShowString(5+8,222,450, 24, 32, (uint8_t *)" L");
		LCD_Fill(115,222,115+60,222+35,RED);
		LCD_ShowString(115+8,222,450, 24, 32, (uint8_t *)" R");
		LCD_Fill(60,280,60+60,280+35,RED);
		LCD_ShowString(60+8,280,450, 24, 32, (uint8_t *)" D");

		LCD_ShowString(0,60,20, 24, 16,(uint8_t *)"XCP");
		LCD_ShowString(100,60,20, 24, 16,(uint8_t *)"YCP");
	}
	LCD_ShowRealNum(30,60,XSO.currentPulsePos,6,16,0);
	LCD_ShowRealNum(130,60,YSO.currentPulsePos,6,16,0);
};

//外框环绕
void outFrameCtrl_ui2(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[outFrameCtrl])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[outFrameCtrl]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(80,8, 450, 24, 32, (uint8_t *)"Outer frame wrapping");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"Speed+");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"Speed-");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+5,160+10,450, 24, 32, (uint8_t *)"  Go  ");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+12,160+10,450, 24, 32, (uint8_t *)"Pause");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+12,240+10,450, 24, 32, (uint8_t *)"Reset");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
	    LCD_ShowString(5, 60, 100, 16, 16, (uint8_t*)"speed level:");
	    PosInforName();
	}
    LCD_ShowNum(110,60,(10-CO.spinspeed/1000)+1,1,16);
    drawPosInfor();
};

//内框环绕
void innFrameCtrl_ui2(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[innFrameCtrl])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[innFrameCtrl]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(80,8, 450, 24, 32, (uint8_t *)"Inner frame wrapping");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"Speed+");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"Speed-");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+5,160+10,450, 24, 32, (uint8_t *)"  Go  ");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+12,160+10,450, 24, 32, (uint8_t *)"Pause");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+12,240+10,450, 24, 32, (uint8_t *)"Reset");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
		LCD_ShowString(5, 60, 100, 16, 16, (uint8_t*)"speed level:");
		PosInforName();
	}
	LCD_ShowNum(110,60,(10-CO.spinspeed/1000)+1,1,16);
	drawPosInfor();
};

//设置菜单界面//设置菜单界面
void setMenu_ui2()
{
	//初次切换到就进行初始化
		if(!UI.initflag[adjustMenu])
		{
		//清屏
			LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[adjustMenu]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		LCD_DrawLine(0, 160, 180, 160);
		POINT_COLOR = RED;
		LCD_ShowString(120,8, 450, 24, 32, (uint8_t *)"Setting Menu");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"Center");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"Corner");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210,160+10,450, 24, 32, (uint8_t *)"RSView");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350,160+10,450, 24, 32, (uint8_t *)"RedCor");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210,240+10,450, 24, 32, (uint8_t *)"Bframe");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
	}
};


void adjustMenu_ui2(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[setMenu])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[setMenu]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(150,8, 450, 24, 32, (uint8_t *)"Setting Menu");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"Motor");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"Algor");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+5,160+10,450, 24, 32, (uint8_t *)"Param");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+12,160+10,450, 24, 32, (uint8_t *)" ");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+12,240+10,450, 24, 32, (uint8_t *)" ");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
	}
};

void aboutUs_ui2(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[aboutUs])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[aboutUs]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(150,8, 450, 24, 32, (uint8_t *)"About Us");
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
	}
};


//原点设置界面
void homeSetUi3(void)
{
	//初次切换到就进行初始化
	if(!UI.initflag[homeSet])
	{
		//清屏
		LCD_Clear(GRAY);
		BACK_COLOR = GRAY;
		//初始化标志位的处理
		//1.先全部置零
		for(int i=0;i<20;i++)
		{
			UI.initflag[i]=NO;
		}
		//2.再将本模式置一
		UI.initflag[homeSet]=YES;

		POINT_COLOR = WHITE;
		LCD_DrawRectangle(1, 1, 479, 50);
		LCD_DrawLine(180, 51, 180, 319);							//画线
		LCD_DrawLine(0, 160, 180, 160);							//画线
		POINT_COLOR = RED;
		LCD_ShowString(80,8, 300, 24, 32, (uint8_t *)"     Home Set   ");
		LCD_Fill(210,80,310,130,YELLOW);
		BACK_COLOR = YELLOW;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"1 Uint");
		LCD_Fill(350,80,450,130,CYAN);
		BACK_COLOR = CYAN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"5 Uint");
		LCD_Fill(210,160,310,210,WHITE);
		BACK_COLOR = WHITE;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+18,160+10,450, 24, 24, (uint8_t *)"20 Uint");
		LCD_Fill(350,160,450,210,GREEN);
		BACK_COLOR = GREEN;
		POINT_COLOR = BLACK;
		LCD_ShowString(350+5,160+10,450, 24, 24, (uint8_t *)"40 Uint");
		LCD_Fill(210,240,310,290,BROWN);
		BACK_COLOR = BROWN;
		POINT_COLOR = BLACK;
		LCD_ShowString(210+12,240+10,450, 24, 32, (uint8_t *)" Set");
		LCD_Fill(350,240,450,290,LBBLUE);
		BACK_COLOR = LBBLUE;
		POINT_COLOR = WHITE;
		LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
		BACK_COLOR = RED;
		POINT_COLOR = WHITE;
		LCD_Fill(60,165,60+60,165+35,RED);
		LCD_ShowString(60+8,165,450, 24, 32, (uint8_t *)" U");
		LCD_Fill(5,222,5+60,222+35,RED);
		LCD_ShowString(5+8,222,450, 24, 32, (uint8_t *)" L");
		LCD_Fill(115,222,115+60,222+35,RED);
		LCD_ShowString(115+8,222,450, 24, 32, (uint8_t *)" R");
		LCD_Fill(60,280,60+60,280+35,RED);
		LCD_ShowString(60+8,280,450, 24, 32, (uint8_t *)" D");

		LCD_ShowString(0,60,20, 24, 16,(uint8_t *)"XCP");
		LCD_ShowString(100,60,20, 24, 16,(uint8_t *)"YCP");
	}
	LCD_ShowRealNum(30,60,XSO.currentPulsePos,6,16,0);
	LCD_ShowRealNum(130,60,YSO.currentPulsePos,6,16,0);
};

//角点设置界面
void cornerSetUi3(void)
{
  //初次切换到就进行初始化
  if(!UI.initflag[cornerSet])
  {
	  //清屏
	  LCD_Clear(GRAY);
	  BACK_COLOR = GRAY;
	  //初始化标志位的处理
	  //1.先全部置零
	  for(int i=0;i<20;i++)
	  {
		  UI.initflag[i]=NO;
	  }
	  //2.再将本模式置一
	  UI.initflag[cornerSet]=YES;

	  POINT_COLOR = WHITE;
	  LCD_DrawRectangle(1, 1, 479, 50);
	  LCD_DrawLine(180, 51, 180, 319);							//画线
	  LCD_DrawLine(0, 160, 180, 160);							//画线
	  POINT_COLOR = RED;
	  LCD_ShowString(80,8, 300, 24, 32, (uint8_t *)"   Corner Set ");
	  LCD_Fill(210,80,310,130,YELLOW);
	  BACK_COLOR = YELLOW;
	  POINT_COLOR = BLACK;
	  LCD_ShowString(210+18,80+14,100, 24, 24, (uint8_t *)"1 Uint");
	  LCD_Fill(350,80,450,130,CYAN);
	  BACK_COLOR = CYAN;
	  POINT_COLOR = BLACK;
	  LCD_ShowString(350+18,80+14,450, 24, 24, (uint8_t *)"5 Uint");
	  LCD_Fill(210,160,310,210,WHITE);
	  BACK_COLOR = WHITE;
	  POINT_COLOR = BLACK;
	  LCD_ShowString(210+18,160+10,450, 24, 24, (uint8_t *)"40 Uint");
	  LCD_Fill(350,160,450,210,GREEN);
	  BACK_COLOR = GREEN;
	  POINT_COLOR = BLACK;
	  LCD_ShowString(350+5,160+10,450, 24, 24, (uint8_t *)" switch");
	  LCD_Fill(210,240,310,290,BROWN);
	  BACK_COLOR = BROWN;
	  POINT_COLOR = BLACK;
	  LCD_ShowString(210+12,240+10,450, 24, 32, (uint8_t *)" Set");
	  LCD_Fill(350,240,450,290,LBBLUE);
	  BACK_COLOR = LBBLUE;
	  POINT_COLOR = WHITE;
	  LCD_ShowString(350+18,240+10,450, 24, 32, (uint8_t *)"Exit");
	  BACK_COLOR = RED;
	  POINT_COLOR = WHITE;
	  LCD_Fill(60,165,60+60,165+35,RED);
	  LCD_ShowString(60+8,165,450, 24, 32, (uint8_t *)" U");
	  LCD_Fill(5,222,5+60,222+35,RED);
	  LCD_ShowString(5+8,222,450, 24, 32, (uint8_t *)" L");
	  LCD_Fill(115,222,115+60,222+35,RED);
	  LCD_ShowString(115+8,222,450, 24, 32, (uint8_t *)" R");
	  LCD_Fill(60,280,60+60,280+35,RED);
	  LCD_ShowString(60+8,280,450, 24, 32, (uint8_t *)" D");

	  frawCornerName();
  }
  drawCornerVoord();
}

void numKeyPadUi3(void)
{
  //初次切换到就进行初始化
    if(!UI.initflag[numKeyPad])
    {
  	  //清屏
  	  LCD_Clear(GRAY);
  	  BACK_COLOR = GRAY;
  	  //初始化标志位的处理
  	  //1.先全部置零
  	  for(int i=0;i<20;i++)
  	  {
  		  UI.initflag[i]=NO;
  	  }
  	  //2.再将本模式置一
  	  UI.initflag[numKeyPad]=YES;

  	  POINT_COLOR = WHITE;
  	  LCD_DrawRectangle(1, 1, 479, 50);
  	  LCD_DrawLine(180, 51, 180, 319);							//画线
  	  LCD_DrawLine(0, 160, 180, 160);							//画线
  	  POINT_COLOR = RED;
  	  LCD_ShowString(80,8, 300, 24, 32, (uint8_t *)"Set Target X ");
  	  LCD_Fill(210,80,310,130,YELLOW);
    }
}
void uidraw(int index)
{
	if(index<0)
	{
		switch(UI.uiIndex)
		{
		case mainMenu 		: mainMenu_ui1(); break;
		case coorCtrl 		: coorCtrl_ui2(); break;
		case setMenu 		: setMenu_ui2(); break;
		case outFrameCtrl 	: outFrameCtrl_ui2(); break;
		case innFrameCtrl 	: innFrameCtrl_ui2(); break;
		case adjustMenu 	: adjustMenu_ui2(); break;
		case aboutUs 		: aboutUs_ui2(); break;
		case homeSet		: homeSetUi3(); break;
		case cornerSet		: cornerSetUi3(); break;
		case numKeyPad 		: numKeyPadUi3();break;
		default			: mainMenu_ui1(); break;
		}
	}
	else
	{
		UI.uiIndex=index;
		switch(index)
		{
		case mainMenu 		: mainMenu_ui1(); break;
		case coorCtrl 		: coorCtrl_ui2(); break;
		case setMenu 		: setMenu_ui2(); break;
		case outFrameCtrl 	: outFrameCtrl_ui2(); break;
		case innFrameCtrl 	: innFrameCtrl_ui2(); break;
		case adjustMenu 	: adjustMenu_ui2(); break;
		case aboutUs 		: aboutUs_ui2(); break;
		case homeSet		: homeSetUi3(); break;
		case cornerSet		: cornerSetUi3(); break;
		case numKeyPad 		: numKeyPadUi3();break;
		default			: mainMenu_ui1(); break;
		}
	}
}

void frawCornerName(void)
{
	LCD_ShowString(0,140,60, 24, 16, (uint8_t *)"Corner");

	LCD_ShowString(0,60,20, 24, 16, (uint8_t *)"X0");
	LCD_ShowString(80,60,20, 24, 16, (uint8_t *)"Y0");
	LCD_ShowString(0,80,20, 24, 16, (uint8_t *)"X1");
	LCD_ShowString(80,80,20, 24, 16, (uint8_t *)"Y1");
	LCD_ShowString(0,100,20, 24, 16, (uint8_t *)"X2");
	LCD_ShowString(80,100,20, 24, 16, (uint8_t *)"Y2");
	LCD_ShowString(0,120,20, 24, 16, (uint8_t *)"X3");
	LCD_ShowString(80,120,20, 24, 16, (uint8_t *)"Y3");
}

void drawCornerVoord(void)
{
	LCD_ShowNum(50,140,CO.fineindex,2,16);

	LCD_ShowRealNum(20,60,CO.cornerPoint[0].x,6,16,0);
	LCD_ShowRealNum(100,60,CO.cornerPoint[0].y,6,16,0);
	LCD_ShowRealNum(20,80,CO.cornerPoint[1].x,6,16,0);
	LCD_ShowRealNum(100,80,CO.cornerPoint[1].y,6,16,0);
	LCD_ShowRealNum(20,100,CO.cornerPoint[2].x,6,16,0);
	LCD_ShowRealNum(100,100,CO.cornerPoint[2].y,6,16,0);
	LCD_ShowRealNum(20,120,CO.cornerPoint[3].x,6,16,0);
	LCD_ShowRealNum(100,120,CO.cornerPoint[3].y,6,16,0);
}
void PosInforName(void)
{
	LCD_ShowString(0,80,20, 24, 16,(uint8_t *)"XTP");
	LCD_ShowString(100,80,20, 24, 16,(uint8_t *)"XCP");
	LCD_ShowString(0,100,20, 24, 16,(uint8_t *)"YTP");
	LCD_ShowString(100,100,20, 24, 16,(uint8_t *)"YCP");
	LCD_ShowString(0,120,50, 24, 16,(uint8_t *)"Status:");
}
void drawPosInfor(void)
{
	LCD_ShowRealNum(30,80,XSO.taragetPulsePos,5,16,0);
	LCD_ShowRealNum(130,80,XSO.currentPulsePos,5,16,0);
	LCD_ShowRealNum(30,100,YSO.taragetPulsePos,5,16,0);
	LCD_ShowRealNum(130,100,YSO.currentPulsePos,5,16,0);
	if(CO.workStatus == FREE)
	{
		LCD_ShowString(60,120,50, 24, 16,(uint8_t *)"FREE");
	}
	else
	{
		LCD_ShowString(60,120,50, 24, 16,(uint8_t *)"BUSY");
	}
}


//--------------------------------触摸部分--------------------------------------------------------------------
//定义触摸按键区域结构体
RectAreaDef KeyA = {200,325,80,145}; //右左一
RectAreaDef KeyB = {340,460,80,145}; //右右一
RectAreaDef KeyC = {200,325,160,218};//右左二
RectAreaDef KeyD = {340,460,160,218}; //右右二
RectAreaDef KeyE = {200,325,233,290};//右左三
RectAreaDef KeyF = {340,460,233,290};//右右三
RectAreaDef KeyG = {45,125,156,215}; //上
RectAreaDef KeyH = {0,75,220,270};   //左
RectAreaDef KeyI = {100,180,220,270};//右
RectAreaDef KeyJ = {45,125,275,320}; //下

TouchPointDef Touch={0,0};
//区域判决函数
FlagDef earaJudge(RectAreaDef keyearah,TouchPointDef* touchpointh)
{
	return (touchpointh->point.x < keyearah.xh) && (touchpointh->point.x > keyearah.xl) && (touchpointh->point.y < keyearah.yh) && (touchpointh->point.y > keyearah.yl) ? YES : NO;
}

//触摸判决函数
int touchJudge(TouchPointDef* touchpointh)
{
	int index=0;
	if (earaJudge(KeyA,touchpointh))
		{
			index = 1;
		}
	else if(earaJudge(KeyB,touchpointh))
		{
			index = 2;
		}
	else if(earaJudge(KeyC,touchpointh))
		{
			index = 3;
		}
	else if(earaJudge(KeyD,touchpointh))
		{
			index = 4;
		}
	else if(earaJudge(KeyE,touchpointh))
		{
			index = 5;
		}
	else if(earaJudge(KeyF,touchpointh))
		{
			index = 6;
		}
	else if(earaJudge(KeyG,touchpointh))
		{
			index = 7;
		}
	else if(earaJudge(KeyH,touchpointh))
		{
			index = 8;
		}
	else if(earaJudge(KeyI,touchpointh))
		{
			index = 9;
		}
	else if(earaJudge(KeyJ,touchpointh))
		{
			index = 10;
		}
	if(touchpointh->flag && index!=0) //点了没松手，第二次被检测到，失能本次触摸，返回0
	{
		return 0;
	}
	else if(!touchpointh->flag&& index!=0) //有效触摸，触摸标志变为失能，返回触摸值
	{
		touchpointh->flag=YES;
		return index;
	}
	else if(index==0) //无操作状态，恢复使能
	{
		touchpointh->flag=NO;
		return 0;
	}
}
//触摸码获取函数
int getTouchCode(int uiIndex)
{
	if(UI.uiIndex==uiIndex)
	{
	  Touch_read();
	  Touch.point.x=Touch_X;
	  Touch.point.y=Touch_Y;
	  return touchJudge(&Touch);
	}
	return 0;
}

void setFeedBack(void)
{
	if(set == 0)
		return;
	else if(set == 1)
	{
		LCD_ShowString(0,80,20, 24, 16,(uint8_t *)"YCP");
	}
}
